﻿using BCCommon.Enums;
using BCEntity.Website.User;
using BCEntity.WeChatComponent.WeChatUserInfo;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace BCData.Website.User.User
{
    /// <summary>
    /// 用户信息数据处理接口
    /// </summary>
    public interface IUserData
    {
        /// <summary>
        /// 唯一码检查用户是否存在
        /// </summary>
        /// <param name="uniqueCode">唯一码</param>
        /// <returns></returns>
        Task<bool> CheckUserExistsByUniqueCode(string uniqueCode);

        /// <summary>
        /// 检查用户是否存在
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <returns></returns>
        Task<bool> CheckUserId(long userId);

        /// <summary>
        /// 创建用户
        /// </summary>
        /// <param name="entity">用户信息</param>
        /// <returns></returns>
        Task<UserEntity> Create(UserEntity entity);

        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <returns></returns>
        Task<UserEntity> GetUserByUserId(long userId);
        /// <summary>
        /// 获取用户Id
        /// </summary>
        /// <param name="uniqueCode">唯一码</param>
        /// <returns></returns>
        Task<long> GetUserId(string uniqueCode);
        /// <summary>
        /// 获取用户信息列表
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="phone">手机号</param>
        /// <param name="identityNumber">身份证编码</param>
        /// <param name="accountStatus">账号状态</param>
        /// <param name="roleType">角色类型</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="ascending">排序</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">当前页大小</param>
        /// <returns></returns>
        Task<(IEnumerable<WeChatUserInfoEntity>,int)> GetUserList(string userName, string phone, string identityNumber, AccountStatus? accountStatus, RoleType? roleType, DateTime? start, DateTime? end, bool? ascending, int pageIndex = 1, int pageSize = 10);

        /// <summary>
        /// 检查用户手机是否已存在
        /// </summary>
        /// <param name="phone">手机号码</param>
        /// <returns></returns>
        Task<bool> CheckUserExistsByPhone(string phone);
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="uniqueCode">唯一码</param>
        /// <returns></returns>
        Task<UserEntity> GetUserByUniqueCode(string uniqueCode);
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="phone">手机号码</param>
        /// <returns></returns>
        Task<UserEntity> GetUserByPhone(string phone);

        /// <summary>
        /// 更新登录信息
        /// </summary>
        /// <param name="phone">手机号码</param>
        /// <param name="ip">访问者ip地址</param>
        /// <param name="addressIp">访问者ip转换地址</param>
        void UpdateLoginInfo(string phone, string ip, string addressIp);

        /// <summary>
        /// 更新用户密码
        /// </summary>
        /// <param name="userEntity">用户信息</param>
        /// <returns></returns>
        Task<bool> UpdatePassword(UserEntity userEntity);

        /// <summary>
        /// 修改用户头像
        /// </summary>
        /// <param name="userEntity">用户信息</param>
        /// <returns></returns>
        Task<bool> UpdateAvatar(UserEntity userEntity);

        /// <summary>
        /// 修改用户为VIP
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns></returns>
        Task<int> UpdateVip(long userId);

        /// <summary>
        /// 修改用户手机
        /// </summary>
        /// <param name="userEntity">用户信息</param>
        /// <returns></returns>
        Task<bool> UpdatePhone(UserEntity userEntity);

        /// <summary>
        /// 用户签到
        /// </summary>
        /// <param name="userEntity">用户信息实体</param>
        /// <returns></returns>
        Task<bool> UserSignIn(UserEntity userEntity);

        /// <summary>
        /// 更新验证码
        /// </summary>
        /// <param name="phone">手机号</param>
        /// <param name="passCode">验证码</param>
        /// <param name="passExpirationTime">过期时间</param>
        /// <returns></returns>
        Task<bool> UpdatePassCode(string phone, string passCode, DateTime passExpirationTime);

        /// <summary>
        /// 登陆并返回UnionId
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        Task<UserEntity> GetUserWithUnionIdByPhone(string phone);

        /// <summary>
        /// 修改用户昵称
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="userName">用户名</param>
        /// <param name="identityCardNo">身份证号</param>
        /// <returns></returns>
        Task<UserEntity> UpdateUserName(long userId, string userName, string identityCardNo);

        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="userEntity">用户信息</param>
        /// <returns></returns>
        Task<UserEntity> UpdateUserInfo(UserEntity userEntity);

        /// <summary>
        /// 修改用户信息--用户认证时使用
        /// </summary>
        /// <param name="userEntity">用户信息</param>
        /// <returns></returns>
        Task<int> UpdateAuthUserInfo(UserEntity userEntity);
        /// <summary>
        /// 修改用户账号状态
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="accountStatus">账号状态</param>
        /// <returns></returns>
        Task<int> UpdateAccountStatus(long userId, AccountStatus accountStatus);

        /// <summary>
        /// 获取用户信息列表
        /// </summary>
        /// <param name="accountStatus">账号状态</param>
        /// <param name="roleType">角色类型</param>
        /// <returns></returns>
        Task<IEnumerable<UserEntity>> GetUserList(RoleType roleType, AccountStatus accountStatus);
        /// <summary>
        /// 领取红包
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <returns></returns>
        Task<int> ReceiveRedPacket(long userId);
        /// <summary>
        /// 用户实名认证
        /// </summary>
        /// <param name="user">用户信息</param>
        /// <returns></returns>
        Task<UserEntity> RealNameVerifiesAsync(UserEntity user);
        /// <summary>
        /// 用户实名认证审核
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<UserEntity> RealNameVerifiesApproveAsync(UserEntity entity);
        /// <summary>
        /// 更新父级信息
        /// </summary>
        /// <param name="userId">当前用户Id</param>
        /// <param name="parentUserId">父级用户Id</param>
        /// <returns></returns>
        Task<bool> UpdateUserParent(long userId, long parentUserId);
    }
}
